
<?php
$x=$_GET['id'];
//判断
if (isset($_POST['username'])&&isset($_POST['content'])&&$_POST['username']&&$_POST['content']){
    //引进存数据的数组
    $re = include 'xuyuanchang.php';
//引进各种函数
    include 'functions.php';
    //设置东八地区的时间
        date_default_timezone_set('PRC');
//把上传进来的图像数组分解
    $file = pathinfo($_FILES['file']['name']);

//从新命名
    $ming = 'uploads/' . time() . '.' . $file['extension'];

//将上传的文件移动到新文件夹里面
    move_uploaded_file($_FILES['file']['tmp_name'], $ming);

        $re = include 'xuyuanchang.php';
//覆盖了在数据库里面的ID号数组
        $re[$_GET['id']] = array(
            'username' => $_POST['username'],
            'content' => $_POST['content'],
            'time' => date('y/m/d h:i:s'),
            'ming' => time() . '.' . $file['extension']
        );
//编辑成字符串
        $str = "<?php \n\r return " . var_export($re, true) . "\n\r ?>";
//再复制回去原本的PHP里面
        file_put_contents('xuyuanchang.php', $str);

        echo '
<script>
alert(\'留言成功\');
location.href=\'index.php\'</script>';


}



?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>cenyansen留言板</title>
    <link rel="stylesheet" href="./Css/index.css"/>
    <script type="text/javascript" src='./Js/jquery-1.7.2.min.js'></script>
    <script type="text/javascript" src='./Js/index.js'></script>
</head>
<body>
<div id='top'>
    <span id='send'></span>
</div>
<?php

$er = include 'xuyuanchang.php';


echo "
<div id='send-form' style='	margin-left: -180px;display: block;left: 50%;'>
    <p class='title'><span>留下你路过的证据</span><a href='' id='close'></a></p>
    <form action='' name='wish' method='post' enctype='multipart/form-data'>
        <p>
            <label for='username'>昵称：</label>
            <input type=\"file\" value='头像上传' id=\"file\" name=\"file\" \">
            <img src=".'uploads/'.$er[$_GET['id']]['ming']." alt='' style='width: 135px;height: 100px; float: right;margin-top: -25px;'>
            <input type='text' name='username' id='username' value=".$er[$x]['username'].">
        </p>
        <p>
            <label for='content'>留言：(您还可以输入&nbsp;<span id='font-num'>50</span>&nbsp;个字)</label>
            <textarea name='content' id='content'>".$er[$x]['content']."</textarea>
           
        <div id='phiz'>
            <img src='./Images/phiz/zhuakuang.gif' alt='抓狂'/>
            <img src='./Images/phiz/baobao.gif' alt='抱抱'/>
            <img src='./Images/phiz/haixiu.gif' alt='害羞'/>
            <img src='./Images/phiz/ku.gif' alt='酷'/>
            <img src='./Images/phiz/xixi.gif' alt='嘻嘻'/>
            <img src='./Images/phiz/taikaixin.gif' alt='太开心'/>
            <img src='./Images/phiz/touxiao.gif' alt='偷笑'/>
            <img src='./Images/phiz/qian.gif' alt='钱'/>
            <img src='./Images/phiz/huaxin.gif' alt='花心'/>
            <img src='./Images/phiz/jiyan.gif' alt='挤眼'/>
        </div>
        </p>
        <input  type='submit' id='send-btn' value=''
               style='display: block;width: 130px;height: 50px;background: url(Images/send-btn.png) no-repeat center center;cursor: pointer;float: right;margin: 10px;border: none;margin-top: -20px;'>
    </form>
</div>";

?>
<!--[if IE 6]>
<script type="text/javascript" src="./Js/iepng.js"></script>
<script type="text/javascript">
    DD_belatedPNG.fix('#send,#close,.close', 'background');
</script>
<![endif]-->
</body>
</html>